import numpy as np
import scipy.sparse as sp
import torch
import scipy.io as sio
import random

def load_anomaly_detection_dataset(dataset, datadir='data'):
    
    data_mat = sio.loadmat(f'{datadir}/{dataset}.mat')
    adj = data_mat['Network'] # BlogCatalog(5196, 5196) ACM(16484, 16484) Flickr(7575, 7575)
    feat = data_mat['Attributes'] # BlogCatalog(5196, 8189) ACM(16484, 8337) Flickr(7575, 12047)
    truth = data_mat['Label'] # BlogCatalog(5196, 1) ACM(16484,1) Flickr(7575, 1)
    truth = truth.flatten() # BlogCatalog(5196, )

    # <class 'scipy.sparse.csc.csc_matrix'>  ->  <class 'numpy.ndarray'>
    adj = adj.toarray()
    feat = feat.toarray()
    
    
    return adj, feat, truth

# dataset name: Flickr/ACM/BlogCatalog
adj, feat, truth=load_anomaly_detection_dataset("BlogCatalog")